<?php
/**
 * @ClassName: Agent
 * @Description: TODO
 * @author: gydtrade
 * @Date: 2025-11-14 16:33
 * @Version: V1.0.0
 */

namespace app\api\controller\agent;

use app\api\controller\Api;
use app\common\model;
use app\common\utils\GenMpCodeUtil;

class Agent extends Api
{
    function getMemberShareCode()
    {
        $res = GenMpCodeUtil::getMemberShareCode($this->user_id);

        if (isset($res['code']) && $res['code'] == 0) {
            return json($res);
        }

        return json(['code' => 1, 'data' => $res]);
    }

    function getAgentShareCode()
    {
        $res = GenMpCodeUtil::getAgentShareCode($this->user_id);

        if (isset($res['code']) && $res['code'] == 0) {
            return json($res);
        }

        return json(['code' => 1, 'data' => $res]);
    }

    /**
     * 代理列表
     * @return \think\response\Json
     */
    function getAgentList()
    {
        $keyword = input('keyword', '');

        $list = model\Agent::where('name|contact_name|contact_phone|realname|id_card_num', 'like', '%' . $keyword . '%')->select();

        return json(['code' => 1, 'msg' => 'ok', 'data' => $list]);
    }

}